<!doctype html>
<html>
<!--
author:guojunyu
desc:this demo is about blog.
-->
<head>
  <meta charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="shortcut icon" href="static/images/bitbug_favicon.ico" type="image/x-icon" />
  <link href="/static/css/base.css" rel="stylesheet">
  <link href="/static/css/index.css" rel="stylesheet">
  <link href="/static/css/m.css" rel="stylesheet">
  <script src="/static/js/jquery.min.js" type="text/javascript"></script>
  <script src="/static/js/jquery.easyfader.min.js"></script>
  <script src="/static/js/scrollReveal.js"></script>
  <script src="/static/js/common.js"></script>
  <script  charset="utf-8">
      var url = document.location.toString();
      var arrUrl = url.split("//");
      //当前访问的博客博主
      var blog_username = arrUrl[1].split('/')[1];
      var html_body = '';
      token = window.localStorage.getItem('dnblog_token');
      //登陆的用户名
      username = window.localStorage.getItem('dnblog_user');

      $.ajax({
         // 请求方式
         type:"get",
         // url
         url:"http://127.0.0.1:8000/v1/users/"+ blog_username,
         beforeSend: function(request) {
             request.setRequestHeader("Authorization", token);
         },
         success:function (result) {
             if (200 == result.code){
                 console.log(result.data.nickname);
                 $(document).attr('title', '关于'+ result.data.nickname+'的博客');
                 header_html = makeHeader(blog_username, username)
                 html_body += header_html

                 html_body += '<div class="pagebg ab"> </div>';
                 html_body += '<div class="container">';
                 html_body += '<h1 class="t_nav"><span>个人简介</span>';
                 html_body += '<p class="n1">关于我</p>';
                 html_body += '</h1>';
                 html_body += '<div class="news_infos">';
                 //个人描述
                 html_body += '<ul>';
                 if(result.data.info){
                    html_body += result.data.info;
                 }else{
                    html_body += '空空如也'
                 }
                 html_body += '</ul>';
                 html_body += '</div>';
                 html_body += '<div class="sidebar">';
                 html_body += '<div class="about">';
                 //avatar
                 if (result.data.avatar) {
                     var avatar_url = 'http://127.0.0.1:8000/media/'+ result.data.avatar;
                     html_body += '<p class="avatar"> <img src=' + avatar_url + ' alt=""> </p>';
                 }else{
                     html_body += '<p class="avatar"> <img src="/static/images/avatar.jpg" alt=""> </p>';
                 }
                 //nickname
                 html_body += '<p class="abname">';
                 html_body += result.data.nickname;
                 html_body += '</p>';

                 //简介
                 html_body += '<p class="abtext">';
                 if(result.data.sign){
                    html_body += result.data.sign;
                 }else{
                    html_body += '空空如也'
                 }
                 html_body += '</p>';
                 html_body += '</div>';
                 html_body += '</div>';
                 html_body += '</div>';
                 //footer
                 html_body += '<footer id="footer">';
                 html_body += '<p>Design by <a href=# target="_blank">';
                 html_body += result.data.nickname;
                 html_body += '</a>';
                 html_body += '</footer>';
                 $('body').html(html_body);
                 //初始化登出事件
                 loginOut()

                 //下拉菜单
                 $('.nav>li').hover(function () {
                     $(this).children('ul').stop(true, true).show(400);
                 }, function () {
                     $(this).children('ul').stop(true, true).hide(400);
                 });
             }else{
                 alert(result.error)
             }
         }
    });
  </script>
</head>

<body>
</body>

</html>
